package com.zy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.Vo.DeliveredVo;
import com.zy.Vo.PageDeliveredVo;
import com.zy.mapper.DeliveredMapper;
import com.zy.pojo.Delivered;
import com.zy.pojo.Goods;
import com.zy.service.DeliveredService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;
@Service("deliveredService")
public class DeliveredServiceImpl implements DeliveredService {
    @Resource
    private DeliveredMapper deliveredMapper;
    @Override
    public PageDeliveredVo getPageHousedList(Integer pageSize, Integer pageNo, DeliveredVo deliveredVo) {
        Page page = new Page();
        page.setSize(pageSize);
        page.setCurrent(pageNo);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like(!StringUtils.isEmpty(deliveredVo.getDeliveredName()),"delivered_Name",deliveredVo.getDeliveredName())
                .like(!StringUtils.isEmpty(deliveredVo.getDeliveredId()),"delivered_id",deliveredVo.getDeliveredId())
                .like(!StringUtils.isEmpty(deliveredVo.getDeliveredQuantity()),"delivered_Quantity",deliveredVo.getDeliveredQuantity());
        List<Delivered> list=deliveredMapper.getDeliveredPageList(page,queryWrapper);
        System.out.println(page.getTotal()+"+++++++++++++++++++++++++");
        return new PageDeliveredVo(list,page.getTotal());
    }

    @Override
    public void getDelivereDDel(Integer id) {
        deliveredMapper.deleteById(id);
    }

    @Override
    public void getDelivereADDc(Delivered delivered) {
        deliveredMapper.getDeliveredADDc(delivered);
    }

    @Override
    public List<Goods> getDeGoodsList() {
        return deliveredMapper.getDeGoodsList();
    }
}
